const layerUtils = {
    addTileLayer: function(map, url){
        let layer = map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(url));

        return layer;
    },
    addFeatureLayer:function(map, url, index){
        
        let layer = map.addLayer(new esri.layers.FeatureLayer(url,{
            mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
            outFields: ['*'],
            maxAllowableOffset:1,
            opacity: 0.8,
        }), index);

        return layer;
    },
    removeFeatureLayer: function(map, layer){
        if(layer){
            map.removeLayer(layer);
        }
    },
    changeLayerVisibility: function(layer, visible){
        if(layer){
            if(visible == null){
                layer.setVisibility(!layer.visible);
            }else{
                layer.setVisibility(visible);
            }
        }
    },
}

export default layerUtils